package cn.hanyx.coder.design.pattern.behavioral.strategy.demo01;

import java.io.File;

/**
 * Sorter
 * 策略的使用
 *
 * @author hanyx
 * @date 2020/06/04
 */
public class Sorter {
    private static final long GB = 1000 * 1000 * 1000;

    public void sortFile(String path) {
        File file = new File(path);
        long fileSize = file.length();
        fileSize = 1000000L;
        String key;
        if (fileSize < 6 * GB) {
            key = "Quick";
        } else if (fileSize < 10 * GB) {
            key = "External";
        } else if (fileSize < 100 * GB) {
            key = "EoncurrentExternal";
        } else {
            key = "Mapreduce";
        }
        ISortAlg sortAlg = SortFactory.getInstance(key);
        sortAlg.sort(path);
    }
}
